[DowngradePhp81] Skip PHP_VERSION_ID guarded hash() calls in DowngradeHashAlgorithmXxHashRector - #394
Merged
Merged
Conversation
…eHashAlgorithmXxHashRector Mark hash() calls inside a PHP_VERSION_ID guarded ternary/if as version conditioned, so they are skipped like version_compare() guarded calls. Drops the dead scope-based check, which no longer resolves to an IntegerRangeType. Claude-Session: https://claude.ai/code/session_01UCwZigZyZFXK9SNVFLQsRi
TomasVotruba
force-pushed
the
fix-php-version-id-guard-xxhash
branch
from
August 30, 2026 22:30
f7c53af to
198e0e3
Compare
TomasVotruba
enabled auto-merge (squash)
August 30, 2026 22:30
This was referenced Sep 2, 2026
ondrejmirtes
pushed a commit
to phpstan/phpstan
that referenced
this pull request
Sep 2, 2026
The `Rector downgrade PHP tests` job has been red on every phpstan-src
pull request with a single failure: DowngradeHashAlgorithmXxHashRector's
skip_check_phpversion_ternary fixture, where hash('xxh128', $value)
inside a PHP_VERSION_ID >= 80100 guard gets rewritten to md5 instead of
being skipped.
That was fixed upstream in rectorphp/rector-downgrade-php#394, merged
2026-08-30. The rule no longer depends on the guard resolving to an
IntegerRangeType and marks PHP_VERSION_ID guarded calls the way
version_compare() guarded ones already were.
The pinned e77a75a0 is 13 commits behind and predates that. Bumping the
pin and regenerating rector-downgrade-php-composer.lock, which is
needed because composer.json moved in between (PHPUnit 13, and
rector/type-perfect replaced by tomasvotruba/type-coverage) and both
downgrade jobs read that one lock.
Verified by replaying both jobs with the current 2.2.x phar
(2.2.x-dev@7cdfeaa) copied in the way the jobs do it:
vendor/bin/phpunit 647 tests, 2 skipped, no failures
(635 tests, 1 failure at the old pin)
analyse -c ../rector-downgrade-php.neon no errors, and the existing
baseline entry still matches
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
skip_check_phpversion_ternaryfixture regressed:hash('xxh128')inside aPHP_VERSION_ID >= 80100 ?guard was rewritten tomd5instead of being skipped.Two skip paths both stopped catching
PHP_VERSION_IDguards:PHP_VERSION_CONDITIONEDattribute is only set upstream forversion_compare()conditions, notPHP_VERSION_IDbinary ops.IntegerRangeTypewith min80100, but the scope now resolves to a concreteConstantIntegerType, so that branch never triggers.This subscribes the rule to
Ternary/If_, and when their condition is aPHP_VERSION_IDcomparison, marks the innerhash()calls withPHP_VERSION_CONDITIONEDso they are skipped the same wayversion_compare()guarded calls already are. The dead scope-based check is removed.